/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package objects;

import graphic.Graphic;
import graphic.TextureBase;
import java.io.InputStream;
import org.lwjgl.opengl.GL11;
import org.newdawn.slick.Color;
import org.newdawn.slick.TrueTypeFont;
import org.newdawn.slick.util.ResourceLoader;

/**
 *
 * @author Marcin
 */


public class Font2d {
     private TrueTypeFont font_FT;
    public float size_FT = 24; 
    
    public int texID = 0;
    
    private boolean antiAlias = true;
    private java.awt.Font awtFont;
  
    public Font2d(){
        texID=TextureBase.getTexID();
    }
    
    public void init() {
        init(24f);
    }
    
    public void init(float size) {
    // load a default java font
    size_FT = size;
    awtFont = new java.awt.Font("Ariel", java.awt.Font.PLAIN, (int) size_FT);
    font_FT = new TrueTypeFont(awtFont, antiAlias); 
    }
   
    public void init(String adres) {		
        init(adres, 24f);
    }  
    public void init(String adres, float size) {		
    size_FT = size;
    // load font from file
    try {
	InputStream inputStream	= ResourceLoader.getResourceAsStream(adres);
			
	awtFont = java.awt.Font.createFont(java.awt.Font.TRUETYPE_FONT, inputStream);
	awtFont = awtFont.deriveFont(size_FT); // set font size
	font_FT = new TrueTypeFont(awtFont, antiAlias);
			
	} catch (Exception e) {
            e.printStackTrace();
	}       
    }
    public void write(int x_FT, int y_FT, String text, Color color){    
        Graphic.e.bindNr(texID);
        font_FT.drawString(x_FT, y_FT, text, color);
    }
}
